home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Online / tablePlug / rx / img_studio.tpx < prev    next >
Text File  |  1999-09-25  |  963b  |  60 lines

  1. /*
  2.  
  3.     img_studio.tpx v1.0 © 1999 Dave Naylor
  4.  
  5.     Uses ImageStudio to load the images and scale them down.
  6.  
  7.     This tpx uses the ImageStudio internal loaders.
  8.  
  9.     Tested with ImageStudio 2.3.
  10.  
  11.     Args: SIZEX SIZEY JPEG_COMPRESSION
  12.  
  13.     Where:
  14.  
  15.         SIZEX, SIZEY        Size in pixels of the thumbnail
  16.         JPEG_COMPRESSION    Well...
  17.  
  18. */
  19.  
  20. options results
  21.  
  22. parse arg maxsizex maxsizey compression infile outfile
  23.  
  24. infile=strip(infile)
  25. outfile=strip(outfile)
  26.  
  27. address 'IMAGESTUDIO'
  28. OPEN '"'infile'"' FORCE
  29.  
  30. /* Obtain info about the image */
  31.  
  32. IMAGEINFO_GET STEM IMAGE.
  33.  
  34. x = IMAGE.width
  35. y = IMAGE.height
  36.  
  37. /* ...and calculate the thumbnail resolution */
  38.  
  39. comp=trunc((maxsizex/x)*y)
  40.  
  41. if comp<=maxsizey then do
  42.  
  43.  
  44.     SCALE maxsizex comp
  45.     end
  46.  
  47. else do
  48.                                     /* No */
  49.  
  50.     comp2=trunc((maxsizey/y)*x)
  51.  
  52.     SCALE comp2 maxsizey
  53.  
  54. end
  55.  
  56. /* And save the image */
  57.  
  58. SAVE FILE '"'outfile'"' FORMAT "JPEG" ARGS '"QUALITY 'compression'"'
  59.  
  60.